//index.js
//获取应用实例
const app = getApp()
let Axios = require('../../common/js/ajax.js');
var page = 1;
var switch_p = true
Page({
	data: {
		indicatorDots: false, //swiper属性
		duration: 500, //swiper属性
		autoplay:true,
		interval:2000,
		openid: '',
		nickName: '',
		avatarUrl: '',
		curentNav: 0, //当前导航
		page: 1, //当前列表页数
		indexList: [],
		banners: []
	},
	//事件处理函数
	onLoad: function() {
		var _this = this
		this.load = this.selectComponent("#loading");
		Axios.post(app.globalData.baseUrl + 'App/PublicCommon/Article/z_banner', {
			p: 1
		}, (res) => {
			//console.log(res)
			if (res.status == 1) {
				var data = res.info
				_this.setData({
					banners: data
				})
			}
		})
		Axios.post(app.globalData.baseUrl + 'App/PublicCommon/Article/article_list', {
			p: 1
		}, (res) => {
			//console.log(res)
			if (res.status == 1) {
				var data = res.info
				_this.setData({
					indexList: data
				})
				_this.load.loadIng()
			}
		})
	},
	onReady: function() {
		wx.setNavigationBarTitle({
			title: '甄藏说'
		})
	},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {
		var _this = this;
		wx.showLoading({
			title: '玩命加载中',
		})
		if (switch_p) {
			switch_p = false
			page = page + 1;
			Axios.post(app.globalData.baseUrl + 'App/PublicCommon/Article/article_list?p=' + page, {}, (res) => {
				if (res.status == 1) {
					var data = res.info;
					var temp = _this.data.indexList.concat(data)
					_this.setData({
						indexList: temp
					})
				}
				switch_p = true
				wx.hideLoading();
			})
		}
	}
})
